package cn.abellflower.flowerhomehandler.home.controller;

import cn.abellflower.flowerhomehandler.home.resp.RespView;
import cn.abellflower.flowerhomehandler.home.vo.ValidVo;
import org.hibernate.validator.constraints.Length;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * @Description
 * @Author gbzdyf@126.com
 * @Date 2020/12/27 上午10:11
 */
@Validated
@RequestMapping(value = "valid", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RestController
public class ValidController {

    @PostMapping("save")
    public RespView addUserInfo(@RequestBody @Validated(ValidVo.Save.class) ValidVo validVo) {
        return RespView.builder().build();
    }

    @GetMapping("{userId}")
    public RespView getUserInfoById(@PathVariable("userId") @Min(10000000000000000L) Long userId) {
        return RespView.builder().build();
    }

    @GetMapping("getUserName")
    public RespView getUserName(@Length(min = 1, max = 6) @NotNull Long userId) {
        return RespView.builder().build();
    }
}
